package dto

import "apedge/dao"

// 创建节点
type CreateApedgeInferenceReq struct {
	Name                   string            `json:"name" comment:"服务名称" validate:"required,name-checker"`
	Describe               string            `json:"describe" comment:"描述"`
	Models                 []Model           `json:"models" comment:"模型" validate:"required"`
	Envs                   map[string]string `json:"envs" comment:"环境变量"`
	ContainerImage         string            `json:"containerImage" comment:"推理镜像" validate:"required"`
	ContainerImageTag      string            `json:"containerImageTag" comment:"推理镜像版本" validate:"required"`
	ContainerRunCmd        string            `json:"containerRunCmd" comment:"容器运行命令"`
	ContainerRunParams     string            `json:"containerRunParams" comment:"容器运行参数"`
	ContainerPrivilegeMode bool              `json:"containerPrivilegeMode" comment:"容器特权模式"`
	ContainerRestart       string            `json:"containerRestart" comment:"容器重启策略" validate:"required"`
	ContainerNetwork       string            `json:"containerNetwork" comment:"容器网络类型" validate:"required"`
	ContainerPorts         ContainerPorts    `json:"containerPorts" comment:"容器网络端口"`
	NodeIds                []string          `json:"nodeIds" comment:"描述" validate:"required"`
}

type ContainerPorts struct {
	Infer  map[string]string `json:"infer"`
	Others map[string]string `json:"others"`
}

type Model struct {
	Name      string `json:"name" validate:"required"`
	ID        int64  `json:"id" validate:"required"`
	Version   string `json:"version" validate:"required"`
	VersionId int64  `json:"versionId" validate:"required"`
}

type CreateApedgeInferenceRsp struct {
	ServiceId string `json:"serviceId"`
}

// 列表
type GetApedgeInferenceListReq struct {
	PageNum  int64  `form:"pageNum" validate:"required"`
	PageSize int64  `form:"pageSize" validate:"required"`
	Name     string `form:"name"`
	Sort     string `form:"sort"`
}

type GetApedgeInferenceListRsp struct {
	Items []OutApedgeInferenceItem `json:"items"`
	Total int64                    `json:"total"`
}

// node 详情
type GetApedgeInferenceDetailReq struct {
	ServiceId string `uri:"serviceId" validate:"required"`
}

type GetApedgeInferenceDetailRsp struct {
	OutApedgeInferenceItem
}

type OutApedgeInferenceItem struct {
	ID                     int64             `json:"id"`
	OrgId                  int64             `json:"orgId"`
	GroupId                int64             `json:"groupId"`
	UserId                 int64             `json:"userId"`
	UserName               string            `json:"userName"`
	ServiceId              string            `json:"serviceId"`
	Name                   string            `json:"name"`
	Describe               string            `json:"describe"`
	Caller                 string            `json:"caller"`
	StartTime              int64             `json:"startTime"`
	Url                    string            `json:"url"`
	Status                 string            `json:"status"`
	Models                 []dao.ApflowModel `json:"models"`
	Envs                   map[string]string `json:"envs"`
	NodeIds                []string          `json:"nodeIds"`
	ContainerImage         string            `json:"containerImage"`
	ContainerImageTag      string            `json:"containerImageTag"`
	ContainerRunCmd        string            `json:"containerRunCmd"`
	ContainerRunParams     string            `json:"containerRunParams"`
	ContainerPrivilegeMode bool              `json:"containerPrivilegeMode"`
	ContainerResart        string            `json:"containerResart"`
	ContainerNetwork       string            `json:"containerNetwork"`
	ContainerPorts         ContainerPorts    `json:"containerPorts"`
	NodesStatus            string            `json:"nodesStatus"`
	CreatedAt              int64             `json:"createdAt"`
	UpdatedAt              int64             `json:"updatedAt"`
}

// 删除
type DelApedgeInferenceReq struct {
	ServiceId string `uri:"serviceId" validate:"required"`
}

type DelApedgeInferenceRsp struct{}

// 启动 停止 删除
type OpInferenceTaskReq struct {
	Cmd           string `json:"cmd" validate:"required,oneof=start stop"`
	ServiceNodeId string `json:"serviceNodeId" validate:"required"`
}

type OpInferenceTaskRsp struct{}

// service - node
type GetServiceNodeReq struct {
	ServiceId string `uri:"serviceId" validate:"required"`
}

type GetServiceNodeRsp struct {
	Items []OutServiceNodeItem `json:"items"`
	Total int                  `json:"total"`
}

type OutServiceNodeItem struct {
	ID            int64  `json:"id"`
	OrgId         int64  `json:"orgId"`
	GroupId       int64  `json:"groupId"`
	UserId        int64  `json:"userId"`
	UserName      string `json:"userName"`
	ServiceNodeId string `json:"serviceNodeId"`
	NodeId        string `json:"nodeId"`
	NodeName      string `json:"nodeName"`
	ServiceId     string `json:"serviceId"`
	Status        string `json:"status"`
	Url           string `json:"url"`
	CreatedAt     int64  `json:"createdAt"`
	UpdatedAt     int64  `json:"updatedAt"`
}

// 删除
type DelServiceNodeReq struct {
	ServiceNodeId string `uri:"serviceNodeId" validate:"required"`
}

type DelServiceNodeRsp struct{}

// 预测参数
type PredictInfoReq struct {
	ServiceId string `uri:"serviceId" validate:"required"`
}

type PredictInfoRsp struct {
	Center map[string]interface{} `json:"center"`
	Url    string                 `json:"url"`
}
